import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const state = {
  userinfo: {},
  baseUrl: 'https://v2.qidka.com/vcard',
  uploadUrl: 'https://v2.qidka.com/vcard/upload/image',
  token: '',
  // #ifdef MP
  needAuth: true,
  // #endif
  // #ifdef H5
  needAuth: false,
  // #endif
}

const mutations = {
  setToken(state, token) {
    state.token = token
  },
  setUserInfo(state, userinfo) {
    state.userinfo = userinfo
    state.needAuth = false
  },
  clearAuth(state) {
    state.needAuth = true
  },
}

const store = new Vuex.Store({
  state,
  mutations,
})

export default store;
